//
// Created by francklinson on 2021/7/24 AT 23:28.
//
#include <vector>
#include <iostream>


using namespace std;

class Solution {
public:
    vector<int> getMaximumXor(vector<int> &nums, int maximumBit) {
        int allXOR = 0;
        for (auto &x:nums)
            allXOR ^= x;  // 异或结果
        vector<int> ans;
        int maxBit = (1 << maximumBit) - 1;
        for (int i = nums.size() - 1; i >= 0; --i) {
            ans.push_back(allXOR ^ maxBit);
            allXOR ^= nums[i];
            nums.pop_back();
        }
        return ans;
    }
};

int main() {
    vector<int> nums{2, 3, 4, 7};
    Solution solution;
    auto ans = solution.getMaximumXor(nums, 3);
    for (auto &x:ans) cout << x << endl;
    return 0;
}

